#pragma once
#include "geo_alg.h"
GEO_ALG_BEGIN_NAMESPACE
template<class T>
class LineSegment
{
public:
	typedef typename T::value_type	value_type;
	typedef typename T				point_type;
	typedef typename LineSegment<T>	line_seg_type;
	typedef typename line_seg_type&	reference;

	line_seg_type()
		:p1_(0), p2_(0)
	{

	}

	line_seg_type(const point_type& p1, const point_type& p2)
	{
		p1_ = p1;
		p2_ = p2;
	}

	line_seg_type(const line_seg_type& other)
	{
		p1_ = other.p1_;
		p2_ = other.p2_;
	}


	reference move(point_type p)
	{
		p1 += p;
		p2 += p;
		return *this;
	}

	double distance()
	{
		point_type vec = p1 - p2;
		return vec.mod();
	}


public:
	union {
		struct {
			point_type p1_;
			point_type p2_;
		};

		struct {
			point_type start_;
			point_type end_;
		};
	};
};

GEO_ALG_END_NAMESPACE